use "../2_Data/temp/data_covid_province.dta", clear 

collapse (sum) totale_casi, by(date)

sort date

gen daily_increase=totale_casi-totale_casi[_n-1]

tempfile totale
save `totale', replace


use "../2_Data/temp/data_covid_region.dta", clear 

collapse (sum) tamponi totale_osp terapia deceduti, by(date)

sort date

gen daily_deaths=deceduti-deceduti[_n-1]
gen daily_hosp=totale_osp-totale_osp[_n-1]
gen daily_icu=terapia-terapia[_n-1]


merge 1:1 date using `totale', assert(match) nogen

local var1 daily_increase
local var2 daily_deaths
local var3 daily_hosp
local var4 daily_icu

local figure "_epid_trends"

twoway  (bar `var1' date, color(erose)) (bar `var2' date, color(sand)) (bar `var3' date, color(eltgreen)) , xline(22095, lpattern("--") lcolor(gs10)) xline(22203, lpattern("--") lcolor(gs10)) xline(22150, lcolor(red)) xtitle("") ytitle("") ///
graphregion(fcolor(white) color(white)) scheme(s1mono) xlabel(,labsize() angle(45)) ylabel(0 "0" 10000 "10K" 20000 "20K" 30000 "30K" 40000 "40K", angle(0) labsize(large) axis(1)) /// 
legend(size() label(1 "Daily infections") label(2 "Daily deaths") label(3 "Daily variation in hospitalized") cols(1) region(lcolor(white)) just(left) position(11) ring(0) bplacement(nw) bmargin()) xsize(7.2) ysize(4)

